package com.jcl.core.security;

import com.jcl.core.security.entity.ResultEnum;
import com.jcl.core.security.entity.UserDetail;
import com.jcl.core.security.utils.ResultUtil;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName AjaxLogoutSuccessHandler

 * @Author yyliu
 * @Date 2018/12/18 11:29
 * @Version 1.0
 **/
public class AjaxLogoutSuccessHandler implements LogoutSuccessHandler {

    @Override
    public void onLogoutSuccess(HttpServletRequest request,
                                HttpServletResponse response,
                                Authentication authentication) throws IOException, ServletException {
        UserDetail userDetail = (UserDetail) authentication.getPrincipal();


        ResultUtil.success(response,
                ResultEnum.USER_LOGOUT_SUCCESS.getMessage(), ResultEnum.USER_LOGOUT_SUCCESS.getCode(),
                null);

    }
}
